import http from "@/api";
import { ResPage, OrgManager } from "@/api/interface/index";
import qs from "qs";
/**
 * @name 业务规则模块
 */

// 获取请求转化为问题
export const findUpdateRequest = () => {
  return http.get(`/pages/updateRequest!find.action`, {}, { cancel: false });
};

// 修改请求转化为问题
export const updateRequestToProblem = (params: {}, header: string) => {
  let newobj = {};
  if (header != null && header != "") {
    Object.keys(params).forEach(key => {
      newobj[header + "." + `${key}`] = `${params[key]}`;
    });
  }
  return http.post<String>(`/pages/updateRequest!merge.action`, qs.stringify(newobj)); // post 请求携带表单参数  ==>  application/x-www-form-urlencoded
};

//请求规则
//获取规则列表
export const getChangeRuleList = params => {
  return http.post(
    "/pages/callBusinessRule!findRules.action?flagName=saveChange,changeProce",
    qs.stringify({
      page: params.pageNum,
      rows: params.pageSize,
      sidx: "ruleNo",
      sord: "desc",
      "ruleQueryDTO.description": params["ruleQueryDTO.description"],
      "ruleQueryDTO.ruleName": params["ruleQueryDTO.ruleName"]
    })
  );
};
